package com.alks.yn_zs.controller;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.page.PageParam;
import com.alks.entity.data.page.PageRecord;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.yn_zs.data.dto.LastStkDto;
import com.alks.yn_zs.data.dto.StatsDto;
import com.alks.yn_zs.service.ILastShowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author MS
 * @since 2024/12/20下午4:56
 */
@RestController
@ApiRestController("/last/show")
@Api(value = "生产", tags = "成型看板")
@Slf4j
public class LastShowController {
    @Autowired
    private ILastShowService service;

    @WebLogger
    @PostMapping("/dept/status")
    @ApiOperation(value = "部门产能柱状图", tags = "成型看板")
    public ResponseInfo deptStatus(@RequestParam(required = false)String deptName) {
        Map<String, List<StatsDto>> dtoMap = service.deptStatus(deptName);
        return ResponseInfo.ok(dtoMap);
    }

    @WebLogger
    @PostMapping("/stk/status")
    @ApiOperation(value = "配套库存柱状图", tags = "成型看板")
    public ResponseInfo stkStatus() {
        List<StatsDto> dtoList = service.stkStatus();
        return ResponseInfo.ok(dtoList);
    }

    @WebLogger
    @PostMapping("/stk/detail")
    @ApiOperation(value = "面底库存明细", tags = "成型看板")
    public ResponseInfo stkDetail(@RequestBody PageParam request,
                                    @RequestParam(required = false)@ApiParam("传1筛选出入库数量不为空数据") Integer inFlag,
                                  @RequestParam(required = false)@ApiParam("传1筛选出库存数量不为空数据")  Integer stkFlag) {
        PageRecord<LastStkDto> dtoList = service.stkDetail(request,inFlag, stkFlag);
        return ResponseInfo.ok(dtoList);
    }

}